<?php
session_start();
include 'header.php';?>
    <div class="container_12 primary_content_wrap clearfix">
        <div class="clearfix">
            <div class="top-content">
                <div class="grid_12">
                    <div class="widget-main" id="my_poststypewidget-3">
                        <div class="extra-wrap">
                            <h3>Thông tin giỏ hàng</h3>
                        </div>
                        <div class="extra-wrap">
                            <style>
                                table, th, td {
                                    border: 1px solid black;
                                    border-collapse: collapse
                                }
                            </style>
                            <form method="post" action="updateCart.php">
                                <table style="width: 100%;text-align: center;color: #000000">
                                    <thead>
                                    <tr>
                                        <th>Mã sản phẩm</th>
                                        <th>Tên sản phẩm</th>
                                        <th>Giá (VND)</th>
                                        <th>Số lượng</th>
                                        <th>Xóa</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php
                                    if (!empty($_SESSION['cart'])) {
                                        foreach ($_SESSION['cart'] as $k => $v) {
                                            ?>
                                            <tr>
                                                <td><?php echo $k; ?></td>
                                                <td><?php echo $v['name']; ?></td>
                                                <td><?php echo $v['price']; ?></td>
                                                <td><input type="number" name="qty[]" min=1
                                                           value="<?php echo $v['qty']; ?>"/></td>
                                                <td><a href="deleteCart.php?ime=<?php echo $k ?>">Xóa</a></td>
                                            </tr>
                                        <?php
                                        }
                                    } else {
                                        echo '<tr><td colspan="5">Ban khong co mon hang nao trong gio hang</td></tr>';
                                    }
                                    ?>
                                    </tbody>
                                </table>
                                <br>
                                <input type="submit" value="Cập nhật"/>
                                <?php if (!empty($_SESSION['cart'])) { ?>
                                    <input type="button" value="Thanh toán"
                                           onclick="window.location.href='checkIn.php'"/>
                                <?php } ?>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
<?php
include 'footer.php';?>